home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
036a
/
pmfinder.zip
/
ARC.C
next >
Wrap
Text File
|
1991-12-05
|
3KB
|
114 lines
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h> /* needed for open, close, read, write, */
/* filelength, and eof */
#include <fcntl.h> /* needed for open mode arguments */
#include <sys\types.h> /* needed for file types */
#include <sys\stat.h> /* needed for status flags */
#include <malloc.h> /* needed for _memmax, malloc. and free */
#include "archive.h"
#include "arc.h"
extern BOOL pascal fContinue;
/*
This module performs the ARC and PAK file search.
These functions have changed slightly from
Don A. Williams orginal code.
I've removed references to global variables.
*
*/
/***********************************************************************
* DoArc is the main routine to process an entire Arc file *
***********************************************************************/
void
DoArc (char *Pattern,char *Path,HWND hwndListBox)
{
FILE *ArcFile;
ARCHIVE_HEADER ArchiveHead;
char szListBox[260];
char V_Name[14], V_Path[65];
int Status;
if ( (ArcFile = fopen(Path, "rb")) == NULL )
{
strcpy(szListBox,
"ArcFile Error - Unable to open - ");
strcat(szListBox,Path);
AddToListBox(hwndListBox,szListBox);
}
else
{
while ( (Status = GetEntryArc(ArcFile, &ArchiveHead)) != 0 && fContinue )
{
if (Status < 0)
{
if (Status == -1)
{
strcpy(szListBox,
"ArcFile Error - Unable to read header - ");
strcat(szListBox,Path);
AddToListBox(hwndListBox,szListBox);
break;
}
else
{
if (Status == -2)
{
strcpy(szListBox,
"ArcFile Error - Invalid ArcMark - ");
strcat(szListBox,Path);
AddToListBox(hwndListBox,szListBox);
break;
}
else
{
strcpy(szListBox,
"ArcFile Error - Unknown error - ");
strcat(szListBox,Path);
AddToListBox(hwndListBox,szListBox);
break;
}
}
}
else
{
if ( Match(ArchiveHead.Name,Pattern) )
{
strcpy(V_Name, ArchiveHead.Name);
strcpy(V_Path, Path);
sprintf(szListBox,"%s--> (%s)", V_Path, V_Name);
AddToListBox(hwndListBox,szListBox);
}
}
}
fclose(ArcFile);
}
}
/***********************************************************************
* GetEntryArc will read and verify the next entry in the distributed *
* directory of an ARC or PAK file. *
***********************************************************************/
static int
GetEntryArc (FILE *ArcFile, ARCHIVE_HEADER *ArchiveDir)
{
if (fread(ArchiveDir, sizeof(char), sizeof(ARCHIVE_HEADER), ArcFile) < 2)
{
return(-1);
}
if (ArchiveDir->ArcMark != 0x1A)
{
return(-2);
}
if (ArchiveDir->HeaderVersion == 0) return(0);
fseek(ArcFile, ArchiveDir->Size, SEEK_CUR);
return(1);
}